import { getAction, postAction } from '@/api/manage'

// 表单字段配置 - 列表查询
const basicDynamicFieldConfigList = (params) => getAction('/easyMake/basicDynamicFieldConfig/list', params)
// 表单字段配置 - 新增
const basicDynamicFieldConfigSaveEntity = (data) => postAction('/easyMake/basicDynamicFieldConfig/saveEntity', data)
export default {
  data() {
    return {
      formType: 1,
      tabsList: [
        {
          name: '客户',
          val: 1,
        },
        {
          name: '销售订单',
          val: 2,
        },
        {
          name: '生产订单',
          val: 3,
        },
        {
          name: '生产报工',
          val: 4,
        },
        {
          name: '出入库单',
          val: 5,
        },
        {
          name: '出入库明细',
          val: 6,
        },
        {
          name: '工序',
          val: 7,
        },
        {
          name: '物品',
          val: 8,
        },
      ],
      // 类型
      basicDynamicFieldConfigSaveEntityParams: {
        formType: 1,
        fieldName: '测试字段名',
        fieldType: 1,
        fieldMust: 2,
        placeholder: '请输入测试字段名',
        explanationPrompt: '这是提示文字2',
      },
      form: this.$form.createForm(this, { name: 'coordinated' }),
      formItemRules: ['test', { rules: [{ required: true, message: '请输入内容' }] }],
    }
  },
  created() {
    // 获取列表
    // this.$store.commit('SET_CURRENT_PREFIX', '/jksaas-easyMake')
    this.getBasicDynamicFieldConfigList()
  },
  methods: {
    async getBasicDynamicFieldConfigList() {
      let params = {
        pageNo: 1,
        pageSize: 10,
        formType: this.formType,
      }
      let res = await basicDynamicFieldConfigList(params)
      console.log(res)
    },
    changeTabs(item) {
      this.formType = item.val
      this.getBasicDynamicFieldConfigList()
    },
    async basicDynamicFieldConfigSaveEntityFun() {
      this.basicDynamicFieldConfigSaveEntityParams.formType = this.formType
      let res = await basicDynamicFieldConfigSaveEntity(this.basicDynamicFieldConfigSaveEntityParams)
    },
  },
}
